﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaxFriedrichsModel
{
    public class U
    {
        float density;

        public float Density
        {
            get { return density; }
            set { density = value; }
        }
        float velocity;

        public float Velocity
        {
            get { return velocity; }
            set { velocity = value; }
        }
        float pressure;

        public float Pressure
        {
            get { return pressure; }
            set { pressure = value; }
        }
        float innerEnergy;

        public float InnerEnergy
        {
            get { return innerEnergy; }
            set { innerEnergy = value; }
        }
        float fullEnergy;

        public float FullEnergy
        {
            get { return fullEnergy; }
            set { fullEnergy = value; }
        }
        float adiabat;

        public float Adiabat
        {
            get { return adiabat; }
            set { adiabat = value; }
        }

        float row2;

        public float Row1
        {
            get { return density; }
            set { density = value; }
        }
        public float Row2
        {
            get { return row2; }
            set { row2 = value; }
        }
        float row3;

        public float Row3
        {
            get { return row3; }
            set { row3 = value; }
        }

        //float spectralRadius;

        public float SpectralRadius
        {
            get { return (float)Math.Sqrt(adiabat * pressure / density); }
        }

        public void UpdateValues()
        {
            velocity = row2 / density;
            fullEnergy = Row3;// density * innerEnergy + 0.5f * row2 * velocity;
            innerEnergy = (Row3 - 0.5f * density * velocity * velocity) / density;
            pressure = (adiabat - 1.0f) * density * innerEnergy;
        }
        public void SetFullEnergy()
        {
            fullEnergy = density * innerEnergy + 0.5f * row2 * velocity;
        }
        public void SetRows()
        {
            row2 = density * velocity;
            row3 = density * innerEnergy + 0.5f * row2 * velocity;
        }
        public override string ToString()
        {
            return "density: " + density + " velocity: " + velocity +
                    " inEnergy: " + innerEnergy + " fullEnergy: " + fullEnergy;
                    //+" row1: " + Row1 + " row2: " + Row2 + " row3 " + Row3; 
        }
    }
}
